<?php require_once('../../core/import.php');?>
<?php User::Permission('NEWS_UPDATE'); ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=8" />
    <script type="text/javascript" src="../../scripts/import.js"></script>
    <script type="text/javascript" src="../../scripts/components/kindeditor/import.kindeditor.js"></script>
    <script type="text/javascript" src="scripts/edit.js"></script>
	<script type="text/jscript" src="scripts/oc_upload.js"></script>
<!--二级联动开始-->
    <script language="JavaScript"> 
<?php
	$Data=DB::GetRows('select Identifying,Name,Identifying_Parent from `news_class` where Identifying_Parent is not null');
	$Data_Len=count($Data);
	$j=0
?>

	var num;
	var calArray=new Array();
<?php
	 for($i=0;$i<$Data_Len;$i++){
		 $Row_Class=$Data[$i]
?>
	calArray[<?php echo $i;?>]=new Array("<?php echo $Row_Class["Identifying"];?>","<?php echo $Row_Class["Name"];?>","<?php echo $Row_Class["Identifying_Parent"];?>");
<?php
$j=$j+1;
	 }
?>
	num=<?php echo $j;?>;
	function givevalue(myvalue){
	document.Form1.SecondClass.length = 0;
	    for (i=0;i < num; i++)
		  {
			if (calArray[i][2] == myvalue)
			{
			 document.Form1.SecondClass.options[document.Form1.SecondClass.length] = new Option(calArray[i][1], calArray[i][0],"","");
			     
			     }       
		   }
	}
	</script>
<!--二级联动结束-->
</head>

<body>
    <form id="Form1" name="Form1" method="post" enctype="multipart/form-data" action="edit.action.php" class="Form">
       <?php
	 	#赋值检测
  		if(!is_numeric($ID=Functions::UrlArgs('id'))) exit('信息ID不正确');
    
 	 	#获取数据
	 	$Rows=DB::GetRowByID('news',$ID);
	 ?> 
        <fieldset>
            <legend>基本信息</legend>
            <table width="100%" cellpadding="1" cellspacing="0">
            <tr>
                <td width="130" height="25" align="left">标题：</td>
                <td width="910" colspan="2">
                    <input type="text" id="Title" name="Title"  size="100" value="<?php echo $Rows['Title'];?>" class="Textbox" />
                </td>
            </tr>
             <tr>
                <td height="25" align="left" valign="middle">缩略图：</td>
                <td colspan="2"><input type="File" id="Thumbnail" name="Thumbnail" class="Textbox" />
                 <?php if($Rows['Thumbnail']){?>
                <a href="<?php echo Config::PATH_RELATIVE_ATTACHMENT_NEWS.'/'.$Rows['Thumbnail']; ?>" target="_blank">点击查看</a><a href="pic_delete.php?id=<?php echo $Rows['ID']?>"> 删除</a>
                <?php } ?>
                </td>
            </tr>
             <tr>
                <td width="130" height="25" align="left">来源：</td>
                <td width="910" colspan="2">
                    <input type="text" id="Origin" name="Origin" size="40" value="<?php echo $Rows['Origin'];?>" class="Textbox" />
                </td>
            </tr>
             <tr>
                <td width="130" height="25" align="left">关键词：</td>
                <td width="910" colspan="2">
                    <input type="text" id="Keywords" name="Keywords" size="40" value="<?php echo $Rows['Keywords'];?>" class="Textbox" />
                 <font color="red" size="-1">（说明：标签间用全角&quot;；&quot;分开，最后一个标签不加&quot;；&quot;）</font></td>
            </tr>
            <tr>
                <td width="130" height="25" align="left">核心提示：</td>
                <td width="910" colspan="2">
               		<textarea id="Summary" name="Summary" style="width:40%; height:100px;"><?php echo $Rows['Summary'];?></textarea>
                </td>
            </tr>
            <tr>
                <td height="25" align="left" valign="top">内容：</td>
                <td colspan="2"><textarea id="Content" name="Content" style="width:100%; height:500px;"><?php echo $Rows['Content'];?></textarea></td>
            </tr>
            <tr>
                <td width="130" height="25" align="left">作者：</td>
                <td width="910" colspan="2">
                    <input type="text" id="Auhtor" name="Auhtor" size="40" value="<?php echo $Rows['Auhtor'];?>" class="Textbox" />
                </td>
            </tr>
           <tr>
                <td width="130" height="25" align="left">相关新闻：</td>
                <td width="910" colspan="2">
                <script type="text/javascript">ocUpload.init(200);</script>
                <table>
                   <tr>
                   	<td>
                    	<hr />
                    </td>
                   </tr>
                <?php
                	$Link=DB::GetRows('select ID,Title,Link from `news_link` where NewsID='.$Rows['ID'].' order by ID asc');
					 foreach($Link as $Links)
        			{
				?>
		  		   <tr>
                    <td>
                    	新闻标题：<INPUT TYPE="text" id="news_title_old" NAME="news_title_old" value="<?php echo $Links['Title'] ?>" size="40" class="button1">
		  			 	链接地址：<INPUT TYPE="text" id="news_url_old" NAME="news_url_old" value="<?php echo $Links['Link'] ?>" size="40" class="button1">
		  			    <INPUT TYPE="hidden" id="news_num_old" NAME="news_num_old" value="<?php echo $Links['ID'] ?>">
		    		  	<a href="select_news_delete.php?id=<?php echo $Links['ID'] ?>">移除</a>
               		</td>
                   </tr>
                <?php
					}
				?>
                </table>
                </td>
            </tr>
               </table>
        </fieldset>
	  <fieldset>
            <legend>其它选项</legend>
            <table width="100%" cellpadding="1" cellspacing="0">
            <tr>
                <td width="130" height="25" align="left" valign="middle">类别：</td>
                <td width="910" colspan="2">
                <select name="FirstClass" size="1" id="FirstClass" onChange="givevalue(document.Form1.FirstClass.options[document.Form1.FirstClass.selectedIndex].value)">
	  		<option value="">--请选择一级类别--<?php echo $Rows['ClassID']; ?></option> 
			<?php	
			$data=DB::GetRows('select Identifying,Name from `news_class` where Identifying_Parent is null');
				  foreach($data as $Row)
				  {
                  ?>
                  <option value="<?php echo $Row['Identifying'];?>" <?php if($Row['Identifying']==$Rows['ClassID']){ echo 'selected="selected"' ;}?>> <?php echo $Row['Name'];?></option>
                  <?php 
                   	  }
                  ?>
                  </select>
                  <select name="SecondClass" size="1" id="SecondClass">
                    	 <option value="">--请选择二级类别--</option>
                  <?php
                   	 foreach(DB::GetRows('select Name,Identifying,Identifying_Parent from `news_class` where Identifying_Parent='.$Rows['ClassID'].'') as $Row)
                 		 {
                  ?>
                          <option value="<?php echo $Row["Identifying"];?>" <?php echo $Row['Identifying']==$Rows['SubclassID'] ? 'selected="selected"':'' ;?>><?php echo $Row["Name"];?></option>
                  <?php
                		  }
                  ?>
                  </select>
                </td>
            </tr>
            <tr>
            	<td height="25" align="left" valign="middle">置顶：</td>
            	<td colspan="2"> 
                  	<input type="radio" name="M_IsTop" value="1" <?php if($Rows['M_IsTop']==1){ echo 'checked' ;}?>/> 是&nbsp;
	  			<input type="radio" name="M_IsTop" value="0" <?php if($Rows['M_IsTop']==0){ echo 'checked' ;}?>/> 否 
                  </td>
            </tr>
           <tr>
             	<td height="25" align="left" valign="middle">头条：</td>
            	<td colspan="2"> 
                  	<input type="radio" name="M_IsHeadline" value="1" <?php if($Rows['M_IsHeadline']==1){ echo 'checked' ;}?>/> 是&nbsp;
	  			<input type="radio" name="M_IsHeadline" value="0" <?php if($Rows['M_IsHeadline']==0){ echo 'checked' ;}?>/> 否 
                  </td>
            </tr>
            <tr>
            	<td height="25" align="left" valign="middle">推荐：</td>
            	<td colspan="2"> 
                  	<input type="radio" name="M_IsRecommend" value="1" <?php if($Rows['M_IsRecommend']==1){ echo 'checked' ;}?>/> 是&nbsp;
	  			<input type="radio" name="M_IsRecommend" value="0" <?php if($Rows['M_IsRecommend']==0){ echo 'checked' ;}?>/> 否 
                  </td>
            </tr>
               </table>
        </fieldset>
	  <input type="hidden" id="ID" name="ID" value="<?php echo $ID;?>" />
        <input id="ActionButton" name="ActionButton" type="submit" value="确定" class="button" /> <input id="ResetButton" name="ResetButton" type="reset" value="重置" class="button" />
    </form>
</body>
</html>